export default {
     // 添加数据到数组中
     addToArr(state, payload) {
        let id = state.id++;
        if (payload.trim() == "") return
        let obj = {
          id,
          txt: payload,
          isFinish: false,
          isEdit: false,
        };
        state.arr.unshift(obj);
      },
      // 删除数据
      delItem(state, id) {
        let curIndex = state.arr.findIndex((e) => e.id === id);
        if (!confirm("确认删除吗?")) return;
        state.arr.splice(curIndex, 1);
      },
      // 编辑
      editItem(state, id) {
        let cur = state.arr.find((e) => e.id === id);
        cur.isEdit = !cur.isEdit;
      },
      // 编辑回车
      editF(state, id) {
        let cur = state.arr.find((e) => e.id === id);
        cur.isEdit = false;
      },
      // outInput
      out(state, id) {
        alert("保存成功！");
        let cur = state.arr.find((e) => e.id === id);
        cur.isEdit = false;
      },
  
}